package com.da.javatest.niuke.jianzhi;

import java.util.ArrayList;
import java.util.List;

import com.da.javatest.niuke.common.ListNode;

/**
 * @author chenlida
 * @date 2020/10/26 14:31
 * https://www.nowcoder.com/practice/253d2c59ec3e4bc68da16833f79a38e4?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C55Solution {
    public ListNode EntryNodeOfLoop(ListNode pHead) {
        List<ListNode> list = new ArrayList<>();
        while (pHead != null) {
            if (list.contains(pHead)) {
                return pHead;
            }
            list.add(pHead);
            pHead = pHead.next;
        }
        return null;
    }
}
